import React, { Component } from 'react'
import List from './List'
import Input from './Input'

export default class Todos extends Component {
    constructor(){
        super()
        this.state = {
            list:[
                {id:1,title:"今天要吃的饱饱的"},
                {id:2,title:"明天继续努力努力努力"}
            ]
        }
    }
    add = title=>{
        this.setState({
            list :[...this.state.list,{id:parseInt(Math.random()*10000),title}]
        })
    }
    render() {
        return (
            <div>
                <Input add = {this.add}/>
                <List list = {this.state.list}/>
            </div>
        )
    }
}
